updating oE allocate_string

allocate_string

include machine.e 
namespace machine 
public function allocate_string(sequence s, types :boolean cleanup = 0) 

Allocate a C-style null-terminated string in memory

Parameters:
  1. s : a sequence, the string to store in RAM.
  2. cleanup : an integer, if non-zero, then the returned pointer will be automatically freed when its reference count drops to zero, or when passed as a parameter to delete.
Returns:

An atom, the address of the memory block where the string was stored, or 0 on failure.

Comments:

Only the 8 lowest bits of each atom in s is stored. Use allocate_wstring for storing double byte encoded strings.

There is no allocate_string_low function. However, you could easily craft one by adapting the code for allocate_string.

Since allocate_string allocates memory, you are responsible to free the block when done with it if cleanup is zero. If cleanup is non-zero, then the memory can be freed by calling delete, or when the pointer's reference count drops to zero.

Example 1:
 atom title 
 
title = allocate_string("The Wizard of Oz") 
See Also:

Using Strings, allocate, allocate_wstring

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu